e strict;
 
## Usage info
 if(scalar(@ARGV) != 1)
 {
         print "Usage: $0 <number of dominoes>\n";
             exit 1;
 }
  
# how many dominoes do we want?
  my $dominoes = shift @ARGV;
  chomp $dominoes;
  $dominoes += 0;
   
## Create the "double twelve" collection of dominoes
   my %tuples;
   my $idx = 0;
   for (my $i = 0; $i <= 12; $i++)
   {
           for(my $j = 0; $j <= $i; $j++)
                   {
                               $tuples{$idx++} = "($i,$j)";
                                   }
   }
    
## Spit out a list of dominoes
    while($dominoes-- > 0)
    {
            my @keys = keys %tuples;
                my $key = $keys[int(rand(scalar(@keys)))];
                    print $tuples{$key} . "\n";
                        delete $tuples{$key};
    }
